package com.web.music.model;

import java.util.ArrayList;
import java.util.List;
import javax.persistence.*;

// TODO [done]
// You have to make this class a persistent entity
@Entity
public class Album implements PersistentEntity {

	@Id 
	@Column(name="ALBUM_ID", nullable = false) 
	private Long id;
	
	private String title;
	
	private String review;	
	
	private String year;

	@ManyToOne(cascade={CascadeType.ALL})
	//@JoinColumn(name="ARTIST_ID", nullable = false)
	private Artist artist;
	
	@ManyToMany
	@JoinTable(name="ALBUM_GENRE",
		joinColumns=@JoinColumn(
	  		name="ALBUM_ID",referencedColumnName="ALBUM_ID"),
		inverseJoinColumns=@JoinColumn(
			name="GENRE_ID", referencedColumnName="GENRE_ID"))
	private List<Genre> genres = new ArrayList<Genre>();
	
	@OneToMany(cascade={CascadeType.ALL}, mappedBy="album")
	private List<Track> tracks = new ArrayList<Track>();

	public String getTitle(){
		return title;
	}

	public String getReview(){
		return review;
	}

	public void setReview(String review ){
		this.review = review;
	}

	public void setTitle(String title ){
		this.title = title;
	}

	public List<Genre> getGenres() {
		return genres;
	}

	public void setGenres(List<Genre> genres) {
		this.genres = genres;
	}

	public Artist getArtist() {
		return artist;
	}

	public void setArtist(Artist artist) {
		this.artist = artist;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getYear() {
		return year;
	}

	public void setYear(String year) {
		this.year = year;
	}
	public List<Track> getTracks(){
		return this.tracks;
	}
	public void setTracks(List<Track> tracks){
		this.tracks = tracks;
	}
	public void addTrack(Track track) {
		this.tracks.add(track);
	}

}
